import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDERemoteAction } from './ipsderemote-action';
import { PSDEActionImplBase } from './psdeaction-impl-base';
import { IPSSubSysServiceAPIDEMethod } from '../../service/ipssub-sys-service-apidemethod';

export class PSDERemoteActionImpl extends PSDEActionImplBase implements IPSDERemoteAction {
  protected pssubsysserviceapidemethod: IPSSubSysServiceAPIDEMethod | null = null;

  getPSSubSysServiceAPIDEMethod(): IPSSubSysServiceAPIDEMethod | null {
    if (this.pssubsysserviceapidemethod != null) return this.pssubsysserviceapidemethod;
    const value = this.M.getPSSubSysServiceAPIDEMethod;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.pssubsysserviceapidemethod = ipsdataentity.getPSSubSysServiceAPIDEMust().findPSSubSysServiceAPIDEMethod(value);
    }
    return this.pssubsysserviceapidemethod;
  }

  get psSubSysServiceAPIDEMethod(): IPSSubSysServiceAPIDEMethod | null {
    return this.getPSSubSysServiceAPIDEMethod();
  }

  getPSSubSysServiceAPIDEMethodMust(): IPSSubSysServiceAPIDEMethod {
    const value = this.getPSSubSysServiceAPIDEMethod();
    if (value == null) {
      throw new Error('未指定外部服务接口方法');
    }
    return value;
  }

  get cls(): string {
    return 'PSDERemoteActionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.action.IPSDERemoteAction') return true;
    return super.instanceof(cls);
  }
}
